function a() {
  return new Promise(function (resolve, reject) {
    setTimeout(function () {
      console.log('a');
      // resolve('a 执行完毕')  //then里面的函数才会触发
      reject('a 失败了')
    }, 1000)
  })
}

a()
  .then(res => {
    console.log(res);
  })
  .catch(err => {
    console.log(err);
  })